#include "talk_window.h"

void show_talk_win(){
	GtkWidget *window;
	GdkColor color;
	window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
	gtk_window_set_title(GTK_WINDOW(window), "calou talker window");

	gtk_widget_set_size_request(window, 600, 450);
	
	display_talker_window(window);

	color.blue = 0xffff;
	gtk_widget_modify_bg(GTK_WIDGET(window), GTK_STATE_NORMAL, &color);
	gtk_widget_show_all(window);
}

void display_talker_window(GtkWidget *window){
	
	GtkWidget *scrolled_window_self;
	GtkWidget *scrolled_window_show_talking;
	GtkWidget *vpaned;
	GtkWidget *text_view_self;
	GtkWidget *text_view_show_talking;
	GtkWidget *image;
	GtkWidget *Namelabel;
	GtkWidget *vbox;
	GtkWidget *hbox;
	GtkTextBuffer *buffer;

	vbox = gtk_vbox_new(FALSE, 3);
	gtk_container_add(GTK_CONTAINER(window), vbox);
	
	hbox = gtk_hbox_new(FALSE, 3);
	gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 3);
	image = gtk_image_new_from_file("./image/1.jpg");
	
	gtk_widget_set_size_request(GTK_WIDGET(image), 32, 32);
	Namelabel = gtk_label_new("friendsName");
	gtk_box_pack_start(GTK_BOX(hbox), image, FALSE, FALSE, 3);
	gtk_box_pack_start(GTK_BOX(hbox), Namelabel, FALSE, FALSE, 3);
	
	vpaned = gtk_vpaned_new();
	gtk_box_pack_start(GTK_BOX(vbox), vpaned, TRUE, TRUE, 3);

	scrolled_window_show_talking = gtk_scrolled_window_new(NULL, NULL);
	gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolled_window_show_talking), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
	text_view_show_talking = gtk_text_view_new();
	gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(scrolled_window_show_talking), text_view_show_talking);
	gtk_text_view_set_editable(GTK_TEXT_VIEW(text_view_show_talking), FALSE);
	gtk_widget_set_size_request(GTK_WIDGET(scrolled_window_show_talking) , 600, 300);

	scrolled_window_self = gtk_scrolled_window_new(NULL, NULL);
	gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolled_window_self), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
	text_view_self =  gtk_text_view_new();
	buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(text_view_self));
	gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(scrolled_window_self), text_view_self);

	gtk_paned_add1(GTK_PANED(vpaned), scrolled_window_show_talking);
	gtk_paned_add2(GTK_PANED(vpaned), scrolled_window_self);

	gtk_container_set_border_width(GTK_CONTAINER(window), 10);
	gtk_widget_show_all(window);
}
